{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "a=2\n",
    "b=4\n",
    "c=[1,2,3]\n",
    "print(c[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##条件判断\n",
    "##if...else..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "良好\n"
     ]
    }
   ],
   "source": [
    "scores_zhang=70\n",
    "\n",
    "if scores_zhang >=90:\n",
    "    print(\"优秀\")\n",
    "elif scores_zhang >=70 and scores_zhang<90:\n",
    "    print(\"良\")\n",
    "else:\n",
    "    print(\"好\")\n",
    "    \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##循环\n",
    "##for... in..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "60\n",
      "45\n",
      "86\n",
      "95\n",
      "73\n",
      "优秀学生人数： 1\n"
     ]
    }
   ],
   "source": [
    "list=[60,45,86,95,73]\n",
    "i=0\n",
    "for student_score in list:\n",
    " print(student_score)\n",
    " if(student_score>=90):\n",
    "  i=i+1\n",
    "print(\"优秀学生人数：\",i)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "scores_math=[60,45,86,95,73]\n",
    "\n",
    "def get_num_perfect(scores):\n",
    "  num_perfect=0\n",
    "  for score in scores:\n",
    "    if score>=90:\n",
    "        num_perfect=num_perfect+1\n",
    "  return num_perfect\n",
    "\n",
    "num_perfect1=get_num_perfect(scores=scores_math)\n",
    "print(num_perfect1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'d:\\\\Lenovo\\\\Desktop\\\\云南大学\\\\开源地理信息系统\\\\Chapter3'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "ename": "UnboundLocalError",
     "evalue": "cannot access local variable 'num_low70' where it is not associated with a value",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mUnboundLocalError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32md:\\Lenovo\\Desktop\\云南大学\\开源地理信息系统\\Chapter3\\test.ipynb 单元格 10\u001b[0m line \u001b[0;36m2\n\u001b[0;32m      <a href='vscode-notebook-cell:/d%3A/Lenovo/Desktop/%E4%BA%91%E5%8D%97%E5%A4%A7%E5%AD%A6/%E5%BC%80%E6%BA%90%E5%9C%B0%E7%90%86%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F/Chapter3/test.ipynb#X11sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmodule\u001b[39;00m \u001b[39mimport\u001b[39;00m get_num_low70\n\u001b[1;32m----> <a href='vscode-notebook-cell:/d%3A/Lenovo/Desktop/%E4%BA%91%E5%8D%97%E5%A4%A7%E5%AD%A6/%E5%BC%80%E6%BA%90%E5%9C%B0%E7%90%86%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F/Chapter3/test.ipynb#X11sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m num_low70\u001b[39m=\u001b[39mget_num_low70(scores\u001b[39m=\u001b[39;49mscores_math)\n\u001b[0;32m      <a href='vscode-notebook-cell:/d%3A/Lenovo/Desktop/%E4%BA%91%E5%8D%97%E5%A4%A7%E5%AD%A6/%E5%BC%80%E6%BA%90%E5%9C%B0%E7%90%86%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F/Chapter3/test.ipynb#X11sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mprint\u001b[39m(num_low70)\n",
      "File \u001b[1;32md:\\Lenovo\\Desktop\\云南大学\\开源地理信息系统\\Chapter3\\module.py:12\u001b[0m, in \u001b[0;36mget_num_low70\u001b[1;34m(scores)\u001b[0m\n\u001b[0;32m     10\u001b[0m \u001b[39mfor\u001b[39;00m score \u001b[39min\u001b[39;00m scores:\n\u001b[0;32m     11\u001b[0m   \u001b[39mif\u001b[39;00m score\u001b[39m<\u001b[39m\u001b[39m70\u001b[39m:\n\u001b[1;32m---> 12\u001b[0m       num_low70\u001b[39m=\u001b[39mnum_low70\u001b[39m+\u001b[39m\u001b[39m1\u001b[39m\n\u001b[0;32m     13\u001b[0m \u001b[39mreturn\u001b[39;00m num_low70\n",
      "\u001b[1;31mUnboundLocalError\u001b[0m: cannot access local variable 'num_low70' where it is not associated with a value"
     ]
    }
   ],
   "source": [
    "scores_math=[60,45,86,95,73]\n",
    "from module import get_num_low70\n",
    "num_low70=get_num_low70(scores=scores_math)\n",
    "print(num_low70)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
